package com.qf.service.impl;

import com.qf.entity.EbookEntry;
import com.qf.mapper.EbookEntryDao;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringRunner;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;

/**
 * @author lenovo
 * @version V1.0
 * @Date 2021/10/4 16:42
 */
@RunWith(SpringRunner.class)
@ContextConfiguration(locations = {
        "classpath:applicationContext-dao.xml",
        "classpath:applicationContext-service.xml"
})
public class EbookEntryServiceImplTest2 {

    @Autowired
    private EbookEntryDao ebookEntryDao;

    @Test
    @Transactional
    public void add() {
        EbookEntry ebookEntry = new EbookEntry();
        ebookEntry.setId(10);
        ebookEntry.setCategoryId(3);
        ebookEntry.setTitle("test");
        ebookEntry.setSummary("test1");
        ebookEntry.setUploadUser("ttt");
        ebookEntry.setCreateDate(new Date());
        int i = ebookEntryDao.insert(ebookEntry);
    }

    @Test
    public void update() {
        EbookEntry ebookEntry = new EbookEntry();
        ebookEntry.setId(7);
        ebookEntry.setCategoryId(3);
        ebookEntry.setTitle("test2222");
        ebookEntry.setSummary("test122222");
        ebookEntry.setUploadUser("ttt22222");
        ebookEntry.setCreateDate(new Date());
        int i = ebookEntryDao.updateByPrimaryKeySelective(ebookEntry);
    }

    @Test
    public void delete() {
        int i = ebookEntryDao.deleteByPrimaryKey(7);
    }
}